<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery2.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery2.sorted.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/ckform.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquerypicture.js"></script>
    <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/utf8-jsp/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/utf8-jsp/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath}/utf8-jsp/lang/zh-cn/zh-cn.js"></script>
    <script type="application/javascript">

        var ue = UE.getEditor('editor');

        function commit(){
            $("#form3").submit();
        }
    </script>
    <script>
        $(function () {
            //加载大类别
            $.ajax({
                url:"${pageContext.request.contextPath}/btype/getBigCategory",
                type:"post",
                dataType:"json",
                cache:false,
                success:function (rs) {
                    $.each(rs,function (index,element) {
                        var option=" <option value=\""+element.typeid+"\">"+element.typename+"</option>";
                        $("#bigTypeId").append(option);
                    })
                }
            });
        })
        function changeSmallCategory() {
            var categoryId = $("#bigTypeId").val();
            $.ajax({
                url:"${pageContext.request.contextPath}/btype/getSmallCategory",
                type:"post",
                data:{"typeid":categoryId},
                dataType:"json",
                cache:false,
                success:function (rs) {
                    //清空数据
                    $("#smallTypeId option:not(:lt(1))").remove();
                    $.each(rs,function (index,element) {
                        var option=" <option value=\""+element.typeid+"\">"+element.typename+"</option>";
                        $("#smallTypeId").append(option);
                    })
                }
            })
        }
        function saveBlog() {
            $.ajax({
                url:"${pageContext.request.contextPath}/blog/saveBlog",
                type:"post",
                data:$("#blogForm").serialize(),
                dataType:"json",
                cache:false,
                success:function (rs) {
                    if (rs.status==200){
                        alert(rs.msg)
                        window.location="${pageContext.request.contextPath}/blog/blog_list";
                    }else{
                        alert(rs.msg)
                    }
                }
            });
        }

    </script>

    <style type="text/css">
        body {font-size: 20px;
            padding-bottom: 40px;
            background-color:#e9e7ef;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<form action="#" id="blogForm" method="post" class="definewidth m20">
<table class="table table-bordered table-hover m10" style="margin-left:10px;margin-top:3px;">
    <tr>
        <td width="10%" class="tableleft">博客类别</td>
        <td>
            <select name="bigTypeId" id="bigTypeId" onchange="changeSmallCategory()">
                <option value="0">大类</option>
            </select>
            <select name="typeFk" id="smallTypeId">
                <option value="0">小类</option>

            </select>
        </td>
    </tr>


    <tr>
        <td class="tableleft">博客标题</td>
        <td><input type="text" name="btitle" id="btitle"/></td>
    </tr>
    <tr>
        <td class="tableleft">关键字</td>
        <td><input type="text" name="GoodsNormalPrice"/></td>
    </tr>
    <tr>
        <td class="tableleft">博客内容</td>
        <td>
            <script id="editor" name="bcontent" id="bcontent" type="text/plain" style="width:800px;height:100px;"></script>
        </td>
    </tr>

    <tr>
        <td class="tableleft"></td>
        <td>
            <a href="javascript:saveBlog()" style="margin-left:5px;"type="submit" class="btn btn-primary" type="button" >保存</a> &nbsp;
            &nbsp;
            <a href="javascript:history.back()" type="button" class="btn btn-success" name="backid" id="backid">返回列表</a>
        </td>
    </tr>
</table>
</form>

</body>
</html>

